import Vue from 'vue'
import App from './App.vue'
// 引入vue-router路由
import router from './router'

// 载入全局css配置
import './assets/global.css'

// 载入自定义ElemenyUI主题
import './assets/style/theme/index.css'

// 载入elementUI
import ElementUI from 'element-ui';

// 引入axios
import  axios from 'axios'
axios.defaults.baseURL = 'http://localhost:3000/' // nodeJS Express.js 后端请求路径基准地址
axios.interceptors.request.use(config => {
  // 为请求头对象添加token令牌验证的Authorization字段
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})

// 引入echarts
import * as echarts from 'echarts'

// 引入videoJS
import videoJS from 'video.js'
import 'video.js/dist/video-js.css'
import 'videojs-flash'; // 要播放rtmp流, 必须引入

// 引入 revealJS的样式
import "reveal.js/dist/reveal.css"
import "reveal.js/dist/theme/white.css"

Vue.use(ElementUI);

Vue.prototype.$echarts = echarts;
Vue.prototype.$http = axios;
Vue.prototype.$video = videoJS

// 时间戳转换年月日时分秒-过滤器
Vue.filter('dateFormat', function (originVal) {
  const dt = new Date(originVal)

  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')

  const hh = (dt.getHours() + '').padStart(2, '0')
  const mm = (dt.getMinutes() + '').padStart(2, '0')
  const ss = (dt.getSeconds() + '').padStart(2, '0')
  // `yyyy-mm-dd hh:mm:ss`
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App),
}).$mount('#app')
